<?php

namespace app\admin\traits;

use app\common\service\WeginService;

/**
 *  加入uniacid全局搜索条件和自动入口uniacid
 */
trait ScopeUniacid
{
    // 定义全局的查询范围

    public function scopeUniacid($query)
    {
        if( WeginService::getUniacid())
            $query->where('uniacid', WeginService::getUniacid());
    }
    public static function onBeforeInsert($model)
    {
        $model->uniacid = WeginService::getUniacid();
    }

    public static function onBeforeUpdate($model)
    {
        $model->uniacid = WeginService::getUniacid();
    }

}